package com.neusoft.neumooc.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.core.common.BaseService;
import com.neusoft.core.common.exception.DAOException;
import com.neusoft.core.common.exception.ServiceException;
import com.neusoft.neumooc.dao.UserDAO;
import com.neusoft.neumooc.vo.UserVO;


@Service
@Transactional
public class UserServiceImpl extends BaseService implements UserService{
	
	/**
	 * @Fields userDAO : 用户数据访问类
	 */
	@Autowired
	UserDAO userDAO;
	
	/** 
	 * @Title: getUserByName 
	 * @Description:通过用户名获取用户
	 * @param userName 登录用户名
	 * @return Map<String, Object> 用户名
	 * @throws ServiceException
	 */
	@Override
	public Map<String, Object> getUserByName(String userName)  throws ServiceException{
		return userDAO.getUserByName(userName);
	}
	
	/** 
	 * @Title: queryUserNum 
	 * @Description:获取用户数量
	 * @return int
	 * @throws DAOException
	 */
	@Override
	public int queryUserNum() throws DAOException {
		return userDAO.queryUserNum();
	}
	
	/** 
	 * @Title: getUsers 
	 * @Description:获取用户列表
	 * @param pageNo，pageSize
	 * @return List
	 * @throws DAOException
	 */
	@Override
	public List<UserVO> getUsers(int pageNo, int pageSize) throws DAOException {
		return userDAO.getUsers(pageNo, pageSize);
	}
	
	/** 
	 * @Title: addUser 
	 * @Description:添加用户
	 * @param userVO 用户信息
	 * @return boolean 成功、失败
	 * @throws ServiceException
	 */
	@Override
	public boolean addUser(UserVO userVO) throws ServiceException {
		return userDAO.addUser(userVO);
	}
 
	/** 
	 * @Title: updateUser 
	 * @Description:更新用户信息
	 * @param userVO 用户信息
	 * @return boolean 成功、失败
	 * @throws ServiceException
	 */
	@Override
	public boolean updateUser(UserVO userVO) throws ServiceException {
		return userDAO.updateUser(userVO);
	}
	
	/** 
	 * @Title: getUser 
	 * @Description:通过id获取用户
	 * @param userId 用户id
	 * @return Map<String, Object>
	 */
	@Override
	public Map<String, Object> getUser(String userId) {
		return userDAO.getUser(userId);
	}

	/** 
	 * @Title: getUserInfo 
	 * @Description:通过id获取用户信息
	 * @param userId 用户id
	 * @throws ServiceException
	 */
	@Override
	public UserVO getUserInfo(String userId) throws ServiceException {
		return userDAO.getUserInfo(userId);
	}

	/** 
	 * @Title: deleteUser 
	 * @Description:通过id删除用户
	 * @param userId 用户id
	 * @return int
	 */
	@Override
	public int deleteUser(String userId) {
		 return this.userDAO.deleteUser(userId);
	}

	/** 
	 * @Title: updateStatus 
	 * @Description:启用用户
	 * @param status 状态
	 * @return void 1
	 * @throws ServiceException
	 */
	@Override
	public void updateStatusOn(String status) throws ServiceException {
		userDAO.updateStatusOn(status);
	}

	/** 
	 * @Title: updateStatus2 
	 * @Description:停用用户
	 * @param status 状态
	 * @return void 0
	 * @throws ServiceException
	 */
	@Override
	public void updateStatusOff(String status) throws ServiceException {
		userDAO.updateStatusOff(status);
	}
	
}
